package org.wsjy.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.view.UrlBasedViewResolver;
import org.wsjy.model.TContact;
import org.wsjy.service.ContactService;

/**
 * 联系我们中的内容编辑
 * 
 * @Title:
 * @Company:万世极缘工作室
 * @Description:
 * @Author:万世极缘
 * @Since:2016年2月14日
 * @Copyright:Copyright (c) 2016
 * @ModifyDate:
 * @Version:1.1.0
 */
@Controller
@RequestMapping("/contact")
public class ContactController {

    @Autowired
    private ContactService contactService;
    
    /**
     * 客户提交申请信息
     * @param model
     * @return
     * @Description:
     */
    @RequestMapping("/contact_form.asp")
    public String contactForm(ModelMap model) {
        return "contact/contact_form";
    }
    
    @RequestMapping("/contact_submit.asp")
    public String contactSubmit(@RequestParam(value="stName") String stName, @RequestParam(value="stEmail") String stEmail, @RequestParam(value="stPhone", required = false) String stPhone, @RequestParam(value="clContent") String clContent){
        // 保存
        TContact contact = new TContact();
        contact.setStName(stName);
        contact.setStEmail(stEmail);
        contact.setStPhone(stPhone);
        contact.setClContent(clContent);
        contactService.insert(contact);
        // 跳转，否则页面刷新会重复提交
        return UrlBasedViewResolver.REDIRECT_URL_PREFIX + "contact_form.asp";
    }
}
